/**
 * 
 */
package any.desktop.dao.hibernate;

import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import any.desktop.FileItem;
import any.desktop.dao.FileItemDao;

/**
 * TODO: doc me
 * 
 * @author keke<keke@codehaus.org>
 * @revision $Revision: 50 $
 * @version
 */
public class HibernateFileItemDao extends HibernateDaoSupport implements
        FileItemDao {

    public FileItem getFileItemByMD5(final String md5) {
        return (FileItem) getSessionFactory().getCurrentSession()
                .createCriteria(FileItem.class)
                .add(Restrictions.eq("md5", md5)).setMaxResults(1)
                .uniqueResult();
    }

    public FileItemDao save(final FileItem item) {
        getSessionFactory().getCurrentSession().save(item);
        return this;
    }

}
